<!doctype html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Vue2-02-表格案例</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<style>
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    body {
        background-color: #222;
        color: snow;
    }

    table {
        margin: 1rem;
        border-collapse: collapse;

        th, td {
            padding: .5rem 1rem;
            border: 1px solid silver;
            text-align: center;
        }
    }
</style>
<body>
<div id="app">
    <table>
        <thead>
        <tr>
            <th>编号</th>
            <th>姓名</th>
            <th>年龄</th>
            <th>性别</th>
            <th>成绩</th>
            <th>评价</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="(user, index) in users">
            <td>{{ index }}</td>
            <td>{{ user.name }}</td>
            <td>{{ user.age }}</td>
            <td>
                <span v-if="user.gender===1">男</span>
                <span v-else-if="user.gender===0">女</span>
            </td>
            <td>{{ user.score }}</td>
            <td>
                <span v-if="user.score>=70" style="color: lightgreen;">优秀</span>
                <span v-else-if="user.score>=60" style="color: lightsalmon;">及格</span>
                <span v-else style="color: lightcoral;">不及格</span>
            </td>
        </tr>
        </tbody>
    </table>
</div>
<script>
    new Vue({
        el: '#app',
        data: {
            users: [
                {name: 'Tom', age: 20, gender: 1, score: 90},
                {name: 'Rose', age: 21, gender: 0, score: 59},
                {name: 'Mary', age: 22, gender: 0, score: 80},
                {name: 'Jerry', age: 18, gender: 1, score: 60},
            ],
        },
    });
</script>
</body>
</html>